home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / DTS QT Utilities.Aug-95 / Projects & Test Apps / DigitizerShell / TestFunctions.c < prev    next >
Encoding:
Text File  |  1995-07-10  |  8.3 KB  |  245 lines  |  [TEXT/MPCC]

  1. /*
  2.     File:        TestFunctions.c
  3.  
  4.     Contains:    Test functions for Sequence grabber and vdig tests.
  5.  
  6.     Written by:    DTS
  7.  
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <1>         4/25/95    khs        first file
  13.        
  14. */
  15.  
  16.  
  17. // INCLUDES
  18. #include "TestFunctions.h"
  19.  
  20. #include "DTSQTUtilities.h"
  21. #include "MacFramework.h"
  22.  
  23. extern WindowPtr gCaptureWindow;
  24.  
  25. // FUNCTIONS
  26. // ______________________________________________________________________
  27. //• Dump vdig information from the currently selected vdig (used by the sequence grabber).
  28. OSErr ShowVDIGInfo(void)
  29. {
  30.     OSErr anErr = noErr;
  31.     VideoDigitizerComponent vd = NULL;
  32.     DigitizerInfo                      digInfo;
  33.     
  34.     printf("\nINFORMATION: Video Digitizer (default component):\n");
  35.     
  36.     //• Get access to the sequence grabber's vdig.
  37.     vd = SGGetVideoDigitizerComponent( GetDefaultVideoChannel() ); DebugAssert(vd != NULL);
  38.     if(vd == NULL)
  39.     {
  40.         printf("ERROR: Problems getting the vdig component instance from video channel.\n");
  41.         goto Closure;
  42.     }
  43.  
  44.     //• Test for live incoming video signal.
  45.     if(QTUDoesVDIGReceiveVideo(vd))
  46.         printf("Vdig is currently receiving a video signal.\n");
  47.     else
  48.         printf("Vdig is currently NOT receiving a video signal.\n");
  49.     
  50.     //• Get access to the video digitizer information data structure.
  51.     anErr = VDGetDigitizerInfo(vd, &digInfo); DebugAssert(anErr == noErr);
  52.     if(anErr != noErr)
  53.     {
  54.         printf("ERROR: Problems getting Digitizer Information.\n");
  55.         goto Closure;
  56.     }
  57.  
  58.     //• Get information about the vdig type.
  59.     printf("\nVdig Type = ");
  60.     switch (digInfo.vdigType)
  61.     {
  62.         case vdTypeBasic:
  63.             printf("vdTypeBasic (basic video digitizer, does not support any clipping.\n");
  64.             break;
  65.  
  66.         case vdTypeAlpha:
  67.             printf("vdTypeAlpha (supports clipping by means of an alpha channel).\n");
  68.             break;
  69.  
  70.         case vdTypeMask:
  71.             printf("vdTypeMask (supports clipping by means of a mask plane).\n");
  72.             break;
  73.  
  74.         case vdTypeKey:
  75.             printf("vdTypeKey (supports clipping by means of key colors).\n");
  76.             break;
  77.     }
  78.     
  79.     //• Get information about the vdig input capabilities (default ones).
  80.     printf("\nThe vdig handles the following inputs:\n");
  81.     if(digInfo.inputCapabilityFlags & digiInDoesNTSC)
  82.         printf("\tNTSC\n");        
  83.     if(digInfo.inputCapabilityFlags & digiInDoesPAL)
  84.         printf("\tPAL\n");
  85.     if(digInfo.inputCapabilityFlags & digiInDoesSECAM)
  86.         printf("\tSECAM\n");
  87.     if(digInfo.inputCapabilityFlags & digiInDoesGenLock)
  88.         printf("\tGenlock\n");
  89.     if(digInfo.inputCapabilityFlags & digiInDoesComposite)
  90.         printf("\tComposite Video\n");
  91.     if(digInfo.inputCapabilityFlags & digiInDoesSVideo)
  92.         printf("\tS-Video\n");
  93.     if(digInfo.inputCapabilityFlags & digiInDoesComponent)
  94.         printf("\tRGB input video\n");
  95.     if(digInfo.inputCapabilityFlags & digiInDoesColor)
  96.         printf("\tColor input\n");
  97.     if(digInfo.inputCapabilityFlags & digiInDoesBW)
  98.         printf("\tGrayScale input\n");
  99.     
  100.     if(digInfo.inputCurrentFlags & digiInSignalLock)
  101.         printf("\tCurrently the vdig is locked onto the input signal.\n");
  102.         
  103.         
  104.     //• Get information about the vdig output capabilities (default ones).
  105.         printf("\nThe vdig handles the following output cases:\n");
  106.         printf("Pixel Maps of size (bit): ");
  107.     if(digInfo.outputCapabilityFlags & digiOutDoes1)
  108.         printf("1 ");        
  109.     if(digInfo.outputCapabilityFlags & digiOutDoes2)
  110.         printf("2 ");        
  111.     if(digInfo.outputCapabilityFlags & digiOutDoes4)
  112.         printf("4 ");        
  113.     if(digInfo.outputCapabilityFlags & digiOutDoes8)
  114.         printf("8 ");        
  115.     if(digInfo.outputCapabilityFlags & digiOutDoes16)
  116.         printf("16 ");        
  117.     if(digInfo.outputCapabilityFlags & digiOutDoes32)
  118.         printf("32 ");        
  119.  
  120.     printf("\n");
  121.     
  122.     if(digInfo.outputCapabilityFlags & digiOutDoesDither)
  123.         printf("Handles dithering out.\n");
  124.     if(digInfo.outputCapabilityFlags & digiOutDoesStretch)
  125.         printf("Handles stretching of images.\n");
  126.     if(digInfo.outputCapabilityFlags & digiOutDoesShrink)
  127.         printf("Handles shrinking of images.\n");
  128.     if(digInfo.outputCapabilityFlags & digiOutDoesDouble)
  129.         printf("Handles doubling (stretching to quadruple size) of images.\n");
  130.     if(digInfo.outputCapabilityFlags & digiOutDoesQuad)
  131.         printf("Handles stretching image to 16 times original size.\n");
  132.     if(digInfo.outputCapabilityFlags & digiOutDoesQuarter)
  133.         printf("Handles shrinking image to 1/4 times original size.\n");
  134.     if(digInfo.outputCapabilityFlags & digiOutDoesSixteenth)
  135.         printf("Handles shrinking image to 1/16 times original size.\n");
  136.     if(digInfo.outputCapabilityFlags & digiOutDoesRotate)
  137.         printf("Handles rotation of image displayed.\n");
  138.     if(digInfo.outputCapabilityFlags & digiOutDoesHorizFlip)
  139.         printf("Handles horizontal flip of image displayed.\n");
  140.     if(digInfo.outputCapabilityFlags & digiOutDoesVertFlip)
  141.         printf("Handles vertical flip of image displayed.\n");
  142.     if(digInfo.outputCapabilityFlags & digiOutDoesSkew)
  143.         printf("Handles skew of image displayed.\n");
  144.     if(digInfo.outputCapabilityFlags & digiOutDoesBlend)
  145.         printf("Handles blend of image with matte.\n");
  146.     if(digInfo.outputCapabilityFlags & digiOutDoesWarp)
  147.         printf("Handles warp of image (distortion along an axis).\n");
  148.     if(digInfo.outputCapabilityFlags & digiOutDoesHW_DMA)
  149.         printf("Handles DMA writes to screen or offscreen memory.\n");
  150.     if(digInfo.outputCapabilityFlags & digiOutDoesHWPlayThru)
  151.         printf("Handles Playthrough mode (no need for idle time).\n");
  152.     if(digInfo.outputCapabilityFlags & digiOutDoesILUT)
  153.         printf("Handles inverse lookup tables for indexed color modes.\n");
  154.     if(digInfo.outputCapabilityFlags & digiOutDoesKeyColor)
  155.         printf("Handles clipping by using key colors.\n");
  156.     if(digInfo.outputCapabilityFlags & digiOutDoesAsyncGrabs)
  157.         printf("Can operate asynchronously.\n");
  158.     
  159.     if(digInfo.outputCapabilityFlags & digiOutDoesUnreadableScreenBits)
  160.         printf("Vdig might place pixels on the screeen that can't be used when compressing images.\n");
  161.     if(digInfo.outputCapabilityFlags & digiOutDoesCompress)
  162.         printf("Vdig supports compressed source devices.\n");
  163.     if(digInfo.outputCapabilityFlags & digiOutDoesCompressOnly)
  164.         printf("Vdig only provides compressed image data.\n");
  165.     if(digInfo.outputCapabilityFlags & digiOutDoesPlayThruDuringCompress)
  166.         printf("Vdig can't draw images on the screen while it's delivering compressed images.\n");
  167.     
  168.  
  169.     //• Get information about the sizes this vdig could handle.
  170.     printf("\n\nSmallest resizable height = \t%d.\n", digInfo.minDestHeight);
  171.     printf("Smallest resizable width = \t%d.\n", digInfo.minDestWidth);
  172.     printf("Largest resizable height = \t%d.\n", digInfo.maxDestHeight);
  173.     printf("Largest resizable width = \t%d.\n", digInfo.maxDestWidth);
  174.     
  175.     
  176.     //• Get information about the vdig blending capabilities.
  177.     printf("\nBlend level = \t%d (2 if 1-bit mask).\n", digInfo.blendLevels);
  178.  
  179. Closure:
  180.     return anErr;
  181. }
  182.  
  183.  
  184. // ______________________________________________________________________
  185. //• Call the video settings dialog box for the particular sequence grabber.
  186. void SetMyVideoChannelSettings(void)
  187. {
  188.     OSErr anErr = noErr;
  189.     
  190.     anErr = SGSettingsDialog( GetDefaultSGInstance(), GetDefaultVideoChannel(), 0, NULL,
  191.                                             DoTheRightThing, NULL, 0); DebugAssert(anErr == noErr);
  192. }
  193.  
  194.  
  195. // ______________________________________________________________________
  196. //• Call the audio settings dialog box for the particular sequence grabber.
  197. void SetMyAudioChannelSettings(void)
  198. {
  199.     OSErr anErr = noErr;
  200.     
  201.     anErr = SGSettingsDialog( GetDefaultSGInstance(), GetDefaultAudioChannel(), 0, NULL,
  202.                                             DoTheRightThing, NULL, 0); DebugAssert(anErr == noErr);
  203. }
  204.  
  205.  
  206. // ______________________________________________________________________
  207. //• Record to file using a sequence grabber.
  208. void RecordSamplesToFile(void)
  209. {
  210.     OSErr                         anErr = noErr;
  211.     StandardFileReply     reply;
  212.     ComponentInstance     sg = GetDefaultSGInstance();
  213.     
  214.     //• Create file used.
  215.     StandardPutFile("\pName of the movie file:", "\pMOVIE.MOV", &reply);
  216.     if(!reply.sfGood) goto Closure;
  217.     
  218.     //• Tell SG what file we will use.
  219.     anErr = SGSetDataOutput(sg, &reply.sfFile, seqGrabToDisk); 
  220.     DebugAssert(anErr == noErr); if(anErr) goto Closure;
  221.     
  222.     SetWTitle(gCaptureWindow, "\pRecording. Click Mouse  to Stop!");
  223.     
  224.     //• Record until mouse click.
  225.     anErr = SGStartRecord(sg); DebugAssert(anErr == noErr); if(anErr) goto Closure;
  226.     
  227.     while( !Button() )
  228.         SGIdle(sg);
  229.  
  230.     DebugAssert(anErr == noErr); 
  231.     
  232.     //• Stop recording, flush events, start the normal preview mode again.
  233.     anErr = SGStop(sg); DebugAssert(anErr == noErr);
  234.     SetWTitle(gCaptureWindow, "\pMovie captured...");
  235.     
  236.     anErr = SGStartPreview(sg); DebugAssert(anErr == noErr);
  237.     FlushEvents(mDownMask | mUpMask, 0);
  238.     SetWTitle(gCaptureWindow,"\pCapture Window");
  239.     
  240. Closure:
  241.     return;
  242. }
  243.  
  244.  
  245.